import * as TYPES from './types';
const initState = {
	list: [],
	current: null
};

const setArticle = (state, data) => {
	const newState = JSON.parse(JSON.stringify(state));
	newState.current = data;
	return newState;
};
const setArticleList = (state, data) => {
	const newState = JSON.parse(JSON.stringify(state));
	newState.list = data;
	return newState;
};

export default (state = initState, action) => {
	switch(action.type){
	case TYPES.SET_CURRENT_ARTICLE:
		return setArticle(state, action.data);
	case TYPES.GET_ARTICLE_LIST:
		return setArticleList(state, action.data);
	}
	return state;
};
